#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <cstring>

using namespace std;

void exercise1();
void exercise2();
void exercise3();
void exercise4();
void exercise5();
void exercise6();
void exercise7();
void exercise8();
void exercise9();
void exercise10();

int main(){
    exercise10();
    return 0;
}

void exercise1(){
    const int Size = 20;
    cout << "What is your first name?\n";
    char name[Size];
    cin.get(name, Size);
    cin.get();
    cout << "What is your last name?\n";
    char last[Size];
    cin.get(last, Size);
    cin.get();
    cout << "What letter grade do you deserve?\n";
    char lett;
    cin >> lett;
    cout << "What is your age?\n";
    int age;
    cin >> age;
    cout << "Name: " << last << ", " << name << endl;
    cout << "Grade: " << char(lett+1) << endl;
    cout << "Age: " << age << endl;
}

void exercise2(){
    string name;
    string dessert;

    cout << "Enter your name:\n";
    cin >> name;
    cout << "Enter your favorite dessert:\n";
    cin >> dessert;
    cout << "I have some delicious " << dessert;
    cout << " for you, " << name << ".\n";
}

void exercise3(){
    cout << "Enter your first name: \n";
    char name[20];
    cin.get(name, 20);
    cin.get();
    cout << "Enter your last name: \n";
    char last[20];
    cin.get(last, 20);
    cin.get();
    char str[40];
    strcpy(str, name);
    strcat(str, ", ");
    strcat(str, last);
    cout << "Here's the information in a single string: " << str << endl;
}

void exercise4(){
    cout << "Enter your first name: \n";
    string name;
    cin >> name;
    cout << "Enter your last name: \n";
    string last;
    cin >> last;
    string str = ", ";
    cout << "Here's the information in a single string: " << name + str + last << endl;
}

void exercise5(){
    struct CandyBar
    {
        string name;
        float weight;
        int cal;
    };

    CandyBar snack;
    snack =
    {
        "Moch Munch",
        2.3,
        350
    };
    cout << snack.name << " " << snack.weight << " " << snack.cal << endl;
}

void exercise6(){
    struct CandyBar
    {
        string name;
        float weight;
        int cal;
    };

    CandyBar snack[3];
    snack[0] =
    {
        "Moch Munch",
        2.3,
        350
    };

    snack[1] =
    {
        "Snickers",
        5.3,
        1350
    };

    snack[2] =
    {
        "Rachok",
        0.3,
        50
    };



    cout << snack[0].name << " " << snack[0].weight << " " << snack[0].cal << endl;
    cout << snack[1].name << " " << snack[1].weight << " " << snack[1].cal << endl;
    cout << snack[2].name << " " << snack[2].weight << " " << snack[2].cal << endl;
}

void exercise7(){
    struct pizza{
        string company;
        int diametr;
        int weight;
    };

    pizza piz;
    cout << "Enter company of pizza: ";
    getline(cin, piz.company);
    cout << "Enter diamentr of pizza: ";
    cin >> piz.diametr;
    cout << "Enter weight of pizza: ";
    cin >> piz.weight;

    cout << "Pizza: Company - " << piz.company << ". Diametr - " << piz.diametr << ". Weight - " << piz.weight << endl;
}

void exercise8(){
    struct pizza{
        string company;
        int diametr;
        int weight;
    };

    pizza *piz = new pizza;
    cout << "Enter diamentr of pizza: ";
    cin >> piz->diametr;
    cout << "Enter company of pizza: ";
    cin.ignore();
    getline(cin, piz->company);
    cout << "Enter weight of pizza: ";
    cin >> piz->weight;

    cout << "Pizza: Company - " << piz->company << ". Diametr - " << piz->diametr << ". Weight - " << piz->weight << endl;
    delete piz;
}

void exercise9(){
    struct CandyBar
    {
        string name;
        float weight;
        int cal;
    };

    CandyBar *snack =new CandyBar[3];

    snack[0] = {"BulKa Hleba", 0.5, 40};
    snack[1] = {"Chorniy Hleb", 1.3, 500};
    snack[2] = {"Belyi Hleb", 1.2, 670};

    cout << snack[0].name << " " << snack[0].weight << " " << snack[0].cal << endl;
    cout << snack[1].name << " " << snack[1].weight << " " << snack[1].cal << endl;
    cout << snack[2].name << " " << snack[2].weight << " " << snack[2].cal << endl;

    delete [] snack;
}

void exercise10(){
    array<float, 3> test_speed;

    cout << "Enter 3th znachenie of time in row: ";
    cin >> test_speed[0];
    cout << "and next ";
    cin >> test_speed[1];
    cout << "and next ";
    cin >> test_speed[2];

    float sr = (test_speed[0] + test_speed[1] + test_speed[2]) / 3.0;

    cout << "Yo dunno wat write: " << test_speed[0] << " and "
        << test_speed[1] << " and "
        << test_speed[2] << " und middiale " << sr << endl;
}
